package sg.edu.nus.comp.qa.question.parser;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class QuestionMapParser {
private static Log LOGGER = LogFactory.getLog(QuestionMapParser.class);
	
	public void loadFile(String filePath, Map<String, List<Integer>> questionMap){
		try {
			Scanner scanner = new Scanner(new File(filePath));
			while(scanner.hasNext()){
				String line = scanner.nextLine();
				String[] parts = line.split("	");
				int num = Integer.parseInt(parts[1]);
				List<Integer> list = new ArrayList<Integer>();
				questionMap.put(parts[0], list);
				for(int i = 0; i < num; i ++){
					list.add(scanner.nextInt());
				}
				scanner.nextLine();
			}
			scanner.close();
		} catch (FileNotFoundException e) {
			LOGGER.error("File Not Found", e);
		}
	}
}
